package com.ywh.hilttest.test5

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import com.ywh.hilttest.ContainerActivity
import com.ywh.hilttest.test6.SingletonActivity
import com.ywh.hilttest.test6.SingletonSdkActivity
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class FragmentObjectGlobalSingleton1 : Fragment() {

    //全局单例
    @Inject
    lateinit var singletonGlobal: SingletonGlobal
    @Inject
    lateinit var singletonSdkGlobal: SingletonSdkGlobal



//    //同一Activity单例
//    @Inject
//    lateinit var singletonActivity: SingletonActivity
//
//    @Inject
//    lateinit var singletonActivity2: SingletonActivity
//
//
//    //同一Activity单例
//    @Inject
//    lateinit var singletonSdkActivity: SingletonSdkActivity
//
//    @Inject
//    lateinit var singletonSdkActivity2: SingletonSdkActivity

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.e("HiltTest", "SingletonGlobal-hashCode in ${this::class.java.simpleName}:${singletonGlobal.hashCode()}")
        Log.e("HiltTest", "SingletonSdkGlobal-hashCode in ${this::class.java.simpleName}:${singletonSdkGlobal.hashCode()}")

        startActivity(
            Intent(
                activity,
                ContainerActivity::class.java
            ).putExtra("containerClassName", FragmentObjectGlobalSingleton2::class.java.name)
        )
    }
}